//
//  HLLiveAudienceRequest.m
//  YueYue
//
//  Created by hulu001 on 2024/3/12.
//

#import "HLLiveAudienceRequest.h"

@implementation HLLiveAudienceRequest
{
    NSString *_room;
    HLLiveAudienceType _type;
}

- (id)initWithType:(HLLiveAudienceType )type
                room:(NSString *)room
{
    self = [super init];
    
    if (self) {
        _type = type;
        _room = room;
        self.page = 1;
    }
    
    return self;
}

- (NSString *)requestUrl
{
    return @"/get/live/online/audience";
}

- (YTKRequestMethod)requestMethod
{
    return YTKRequestMethodPOST;
}

- (id)requestArgument
{
    switch (_type) {
        case HLLiveAudienceAll:
            return @{@"pageSize":HLListPageSize, @"liveRoomCode": _room, @"pageNum":@(_page)};
            break;
        case HLLiveAudienceLineIn:
            return @{@"pageSize":@(3), @"liveRoomCode": _room, @"pageNum":@(1)};
            break;
    }
    return @{@"pageNum":@(self.page), @"liveRoomCode":_room, @"pageSize":HLListPageSize};
}

- (NSArray <HLLiveUserModel *> *)userList
{
    NSArray *lists = @[];
    
    NSDictionary *data = [self.result valueForKey:@"data"];
    if (![data isKindOfClass:[NSDictionary class]]){
        return lists;
    }
    
    NSArray *records = [data valueForKey:@"records"];
    
    if (records.count > 0) {
       lists = [HLLiveUserModel mj_objectArrayWithKeyValuesArray:records];
    }
    
    return  lists;
}

@end
